package com.tarena.day050;
import java.util.Arrays;
import java.util.Random;
/** Sort 性能测试 */
public class SortPKDemo {
  public static void main(String[] args) {
    //int[] ary={6,1,3,9,7,4};
    //Arrays.sort(ary);//系统API提供排序方法
    int[] ary = new int[50000];
    Random r = new Random();
    for(int i=0; i<ary.length; i++){
      ary[i]=r.nextInt(50000);
    }
    int[] ary1 = Arrays.copyOf(ary, ary.length);
    long t1 = System.currentTimeMillis();
    Arrays.sort(ary);
    long t2 = System.currentTimeMillis();
    SortDemo.selectionSort(ary1);
    long t3 = System.currentTimeMillis();
    //System.out.println(Arrays.toString(ary)); 
    System.out.println(t2-t1);
    System.out.println(t3-t2);
    System.out.println(Arrays.equals(ary, ary1)); 
    
    int index = Arrays.binarySearch(ary, 8);
    System.out.println(index);//-1
    System.out.println(ary[index]); 
    
  }
}







